// Copyright (c) 2009 http://grommet.codeplex.com
// This source is subject to the Microsoft Public License.
// See http://www.opensource.org/licenses/ms-pl.html
// All other rights reserved.

using System;
using Microsoft.SPOT;
using System.Reflection;

namespace Grommet.Linq.Test
{
    public class Program
    {
        public static void Main()
        {
            // Poor man's unit test framework.

            LinqTest tests = new LinqTest();

            // Unfortunately, no GetCustomAttributes(), so going with
            // method names that end with "Test" instead.
            MethodInfo[] testMethods = tests.GetType().GetMethods();

            foreach (MethodInfo info in testMethods)
            {
                int index = info.Name.IndexOf("Test");
                if (index == info.Name.Length - 4)
                {
                    bool passed = true;
                    Debug.Print("\nRunning " + info.Name + "...");
                    try
                    {
                        info.Invoke(tests, null);
                    }
                    catch
                    {
                        passed = false;
                    }
                    Debug.Print(passed ? "Passed." : "Failed.");
                }
            }
        }
    }
}
